import type { Component } from "vue";
import type { ComponentType } from "./types/index";

/**
 * Component list, register here to setting it in the form
 */
import {
  Input,
  // Select,
  // Radio,
  Checkbox,
  AutoComplete,
  Cascader,
  DatePicker,
  InputNumber,
  Switch,
  TimePicker,
  // TreeSelect,
  Slider,
  Rate,
  Divider,
} from "ant-design-vue";

import VbenSelect from "./components/VbenSelect.vue";
import VbenTreeSelect from "./components/VbenTreeSelect.vue";
import VbenRadioGroup from "./components/VbenRadioGroup.vue";
import VbenCheckboxGroup from "./components/VbenCheckboxGroup.vue";
import VbenRadioButtonGroup from "./components/VbenRadioButtonGroup.vue";
import FormGroup from "./components/FormGroup.vue";

import { BasicUpload } from "$/components/Upload";
import { StrengthMeter } from "$/components/StrengthMeter";
import { IconPicker } from "$/components/Icon";
import { CountdownInput } from "$/components/CountDown";
import { Tinymce } from "$/components/Dict/Tinymce";

const componentMap = new Map<ComponentType, Component>();

componentMap.set("Input", Input);
componentMap.set("InputGroup", Input.Group);
componentMap.set("InputPassword", Input.Password);
componentMap.set("InputSearch", Input.Search);
componentMap.set("InputTextArea", Input.TextArea);
componentMap.set("InputNumber", InputNumber);
componentMap.set("AutoComplete", AutoComplete);

componentMap.set("Select", VbenSelect); //Select);
componentMap.set("TreeSelect", VbenTreeSelect); //TreeSelect);
componentMap.set("Switch", Switch);
componentMap.set("RadioButtonGroup", VbenRadioButtonGroup);
componentMap.set("RadioGroup", VbenRadioGroup); //Radio.Group);
componentMap.set("Checkbox", Checkbox);
componentMap.set("CheckboxGroup", VbenCheckboxGroup); //Checkbox.Group);
componentMap.set("Cascader", Cascader);
componentMap.set("Slider", Slider);
componentMap.set("Rate", Rate);

componentMap.set("DatePicker", DatePicker);
componentMap.set("MonthPicker", DatePicker.MonthPicker);
componentMap.set("RangePicker", DatePicker.RangePicker);
componentMap.set("WeekPicker", DatePicker.WeekPicker);
componentMap.set("TimePicker", TimePicker);
componentMap.set("StrengthMeter", StrengthMeter);
componentMap.set("IconPicker", IconPicker);
componentMap.set("InputCountDown", CountdownInput);

componentMap.set("Upload", BasicUpload);
componentMap.set("Divider", Divider);
componentMap.set("FormGroup", FormGroup);
componentMap.set("Tinymce", Tinymce);

export function add(compName: ComponentType, component: Component) {
  componentMap.set(compName, component);
}

export function del(compName: ComponentType) {
  componentMap.delete(compName);
}

export { componentMap };
